#!/usr/bin/env node

var exec = require('child_process').exec;


var tempDirName = "wgitTemp_" + new Date()*1;

var args = process.argv.slice(2).filter(function(arg) {
    return !!arg;
});




!function(){
    if(!args.length){
        return console.log("请使用如下格式：wgit http://path/to/git/rep");
    }

    var reppath = args[0];
    var cmd1 = "git clone "+reppath+ " " +tempDirName;
    var cmd2 = "xcopy "+tempDirName+"\\* %cd%\\ /s/h/e/y && rd %cd%\\"+tempDirName+" /s/q";





    exec(cmd1, function(err,stdout,stderr){
        if(err) {
            return console.log("git clone "+reppath+" 执行失败:" +  err);
        }

        exec(cmd2,function(err,studout,stderr){
            if(err) {
                return console.log("目录移动失败:"+err);
            }
            console.log("ok");
        })
    });
}();

